package cn.edu.gxnu.dsa.lab;

import java.util.Scanner;

import cn.edu.gxnu.dsa.sort.IntType;
import cn.edu.gxnu.dsa.sort.SqListWithSort;

public class Lab8 {

	public static void main(String[] args) {
		int opCode = 3;
		SqListWithSort sequcenceList = null;
		Scanner sc = new Scanner(System.in);

		while (opCode != 0) {
			welcomMsg();
			opCode = sc.nextInt();
			switch (opCode) {
			case 1:
				sequcenceList = new SqListWithSort(20);
				for (int i = 0; i < 20; i++) {
					try {
						sequcenceList.insert(i, new IntType((int) (Math.random() * 100)));
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				sequcenceList.display();
				sequcenceList.sortWithGuard();
				System.out.println("!!!Sorting finished!!!");
				sequcenceList.display();
				break;
			case 2:
				opCode = 0;
			default:
				break;
			}
		}
		sc.close();

	}

	static void welcomMsg() {
		System.out.println("+----------------------------------------+");
		System.out.println("|Lab: A demo for sorting a sequence list |");
		System.out.println("|Author: TANG Zhiyong  Version: 0.1      |");
		System.out.println("|Eclipse Public License - v 1.0          |");
		System.out.println("|Guangxi Normal University               |");
		System.out.println("|                                     	 |");
		System.out.println("|Please select the operation:            |");
		System.out.println("|1 select 20 random numbers and sort them|");
		System.out.println("|2 close this demo                       |");
		System.out.println("+----------------------------------------+");
	}

}
